package com.shixj.demo.latch;

import java.util.concurrent.CountDownLatch;

/**
 * Created by shixj on 2017/9/25.
 * 控制全部结束
 */
public class LatchEnd implements Runnable {
    private final CountDownLatch doneSignal;

    private int index;

    public LatchEnd(CountDownLatch doneSignal, int index) {
        this.doneSignal = doneSignal;
        this.index = index;
    }

    @Override
    public void run() {
        System.out.println("线程"+index+"运行完成，countDown");
            doneSignal.countDown();
    }
}
